{% extends './layout.html'%} {%block main%}
<style>
	h6 {
		margin-bottom: 5px;
	}
	
	i.qrcode {
		cursor: pointer;
	}
	
	#qrcode {
		text-align: center;
		padding: 20px 40px;
		display: none;
	}
	
	#qrcode p {
		padding-top: 30px;
	}
    #pager{
        text-align: center;
    }
</style>
<blockquote class="layui-elem-quote news_search layui-form">
	<form action="">
		<input type=hidden name=type value="{{type}}" />
		<input type=hidden name=page value="{{page}}" />
		<div class="layui-inline">
			<div class="layui-input-inline">
				<h6>期号</h6>
				<input type="text" name=id value="{{id}}" placeholder="期号" class="layui-input search_input">
			</div>

		</div>

		<div class="layui-inline">
			<div class="layui-input-inline">
				<h6>开始时间</h6>
				<input type="text" name=start_time id=start_time value="{{start_time if start_time != '1970-01-01' else ''}}" placeholder="开始时间" class="layui-input search_input">
			</div>
		</div>

		<div class="layui-inline">
			<div class="layui-input-inline">
				<h6>结束时间</h6>
				<input type="text" name=end_time id=end_time value="{{end_time if end_time != '2099-01-01' else ''}}" placeholder="结束时间" class="layui-input search_input">
			</div>
		</div>

		<div class="layui-inline" style=''>
			<h6>&nbsp;</h6>
			<a class="layui-btn layui-btn-normal" onclick='$("form").submit()'>查询</a>
			{#
			<a class="layui-btn addJingji">添加</a> #}
		</div>
	</form>
	<!--<div class="layui-input-inline">
			<input type="text" value="" placeholder="开始时间" class="layui-input search_input">
		</div>
		<div class="layui-input-inline">
			<input type="text" value="" placeholder="结束时间" class="layui-input search_input">
		</div>
		<div class="layui-input-inline">
			<input type="text" value="" placeholder="所属单位" class="layui-input search_input">
		</div>
		<a class="layui-btn search_btn">查询</a>-->
</blockquote>

<div class="layui-form news_list">
	<table class="layui-table">

		<thead>
			<tr>
				<th style="text-align:left;">
					序号</th>
				<th>期号</th>
				<th>开奖号码</th>
				<th>开奖时间</th>
				<th>添加时间</th>
			</tr>
		</thead>

		<tbody class="news_content">
			{%for item in list%}
			<tr>
				<td>{{loop.index + (page - 1) * 20}}</td>
				<td>{{item.id}}</td>

				<td>{{item.cnumber}}</td>
				<td>{{item.open_time}}</td>
				<td>{{item.add_time | fdate}}</td>
			</tr>
			{%endfor%}
		</tbody>
	</table>
</div>
<div id='pager'></div>



{%endblock%} {%block js%}
<script src='/static/js/qrcode.js'></script>
<script>
	layui.use(["laydate", "element", "form", "laypage"], function(laydate, ele, form, laypage) {
		//执行一个laydate实例
		laydate.render({
			elem: '#start_time' //指定元素
		});

		laydate.render({
			elem: '#end_time' //指定元素
		});

		laypage.render({
			elem: 'pager',
			count: '{{count}}' ,//数据总数，从服务端得到
			limit:20	,
            curr :'{{page}}',
			jump: function(obj, first) {
				//obj包含了当前分页的所有参数，比如：
				console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
				console.log(obj.limit); //得到每页显示的条数

				//首次不执行
				if(!first) {
					$('input[name=page]').val(obj.curr);
					$("form").submit();
					//do something
				}
			}
		});

		
	});

	function openWindow(title, href) {
		var index = layui.layer.open({
			title: title,
			type: 2,
			content: href,
			success: function(layero, index) {
				setTimeout(function() {
					//layui.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
					//	tips: 3
					//});

					var iframe = $('iframe');
					var body = $(iframe.contents()).find("body");
					iframe.height($(window).height() - 100)
				}, 100);
			}
		})

		layui.layer.full(index);
	}

	$(function() {

		$('.qrcode').click(function() {
			var id = $(this).attr('data-id');

			var url = "http://www.baidu.com/s" + id
			$('#qrcode > div').html("").qrcode({
				width: 200,
				height: 200,
				text: url
			});

			$('#qrcode > p').html(url);

			layui.layer.open({
				type: 1,
				content: $('#qrcode'),
				title: "推广二维码"
			});
		});

		$(window).one("resize", function() {
			$('.addJingji').click(function() {
				openWindow("添加", "/proxy/addMember.html?");
			});
		}).resize();
	})
</script>
{%endblock%}